<!DOCTYPE html>
<html lang="zh_cn">
	<head>
		<#include "/common/_head.html" />
		<!-- page specific plugin styles -->
	</head>

	<body class="no-skin">
		<#include "/common/_navbar.html" />
		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>

			<#include "/common/_sidebar.html" />
			<div class="main-content">
				<div class="main-content-inner">
					<div class="page-content">
						<#include "/common/_settings.html" />
						<div class="page-header">
							<h1>
								设备管理
								<small>
									<i class="ace-icon fa fa-angle-double-right"></i>
									井场
								</small>
							</h1>
						</div><!-- /.page-header -->
						<div class="row">
							<div class="col-xs-12">
								<div class="row">
									<div class="col-xs-12">
										<div class="table-header">
											所有井场
										</div>

										<!-- <div class="table-responsive"> -->

										<!-- <div class="dataTables_borderWrap"> -->
										<div>
											<form id="tableform" method="post" >
											<table id="table" class="table table-striped table-bordered table-hover">
												<thead>
													<tr>
														<th class="center">
															<label class="position-relative">
																<input type="checkbox" class="ace" />
																<span class="lbl"></span>
															</label>
														</th>
														<th>设备所在层</th>
														<th>名称</th>
														<th>id</th>
														<th>pid</th>
														<th>描述</th>
														<th>备注</th>
														<th>编辑</th>
													</tr>
												</thead>

												<tbody>
													<#list wellGroupList as x>
													<tr>
														<td class="center">
															<label class="position-relative">
																<input type="checkbox" class="ace" value="${x.primary_id!}" name="ids"/>
																<span class="lbl"></span>
															</label>
														</td>
														<td>${x.layer_no!}</td>
														<td>${x.name!}</td>
														<td>${x.id!}</td>
														<td>${x.pid!}</td>
														<td>${x.desc!}</td>
														<td>${x.remark!}</td>
														<td>
															<div class="hidden-sm hidden-xs action-buttons">
																<a class="green" href="/dev_manage/edit/${x.primary_id}">
																	<i class="ace-icon fa fa-pencil bigger-130"></i>
																</a>

																<a class="red delete-dialog" href="#" data-id="${x.primary_id}">
																	<i class="ace-icon fa fa-trash-o bigger-130"></i>
																</a>
															</div>
							
															<div class="hidden-md hidden-lg">
																<div class="inline position-relative">
																	<button class="btn btn-minier btn-yellow dropdown-toggle" data-toggle="dropdown" data-position="auto">
																		<i class="ace-icon fa fa-caret-down icon-only bigger-120"></i>
																	</button>

																	<ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
																		<li>
																			<a href="/dic/edit/${x.id}" class="tooltip-success" data-rel="tooltip" title="Edit">
																				<span class="green">
																					<i class="ace-icon fa fa-pencil-square-o bigger-120"></i>
																				</span>
																			</a>
																		</li>

																		<li>
																			<a href="#" class="tooltip-error delete-dialog" data-rel="tooltip" title="Delete" data-id="${x.primary_id}">
																				<span class="red">
																					<i class="ace-icon fa fa-trash-o bigger-120"></i>
																				</span>
																			</a>
																		</li>
																	</ul>
																</div>
															</div>
														</td>
													</tr>
													</#list>
												</tbody>
											</table>
											</form>
										</div>
										<div class="hr hr-16 hr-dotted"></div>
										<button type="button" class="btn btn-primary" onclick="location.href='/dev_manage/add'">
											<i class="ace-icon fa fa-plus bigger-120"></i>
											新增
										</button>
										&nbsp; &nbsp; &nbsp;
										<button type="button" class="btn btn-danger" onclick="batchDelete(event);">
											<i class="ace-icon fa fa-trash-o bigger-120"></i>
											删除
										</button>
									</div>
								</div>
							</div>
						</div>
						<#include "/common/_sidebar2.html" />
					</div><!-- /.page-content -->
				</div>
			</div><!-- /.main-content -->
			
			<#include "/common/_footer.html" />
		</div><!-- /.main-container -->
		
		<div id="delete-confirm" class="hide">
			<div class="alert alert-info bigger-110">
				这条数据将被删除且无法恢复
			</div>

			<div class="space-6"></div>

			<p class="bigger-110 bolder center grey">
				<i class="ace-icon fa fa-hand-o-right blue bigger-120"></i>
				你确认么?
			</p>
		</div><!-- #dialog-confirm -->
		
		<#include "/common/_script.html" />
		<!-- page specific plugin scripts -->
		<script src="/assets/js/jquery.dataTables.js"></script>
		<script src="/assets/js/jquery.dataTables.bootstrap.js"></script>
		<!-- inline scripts related to this page -->
		<script type="text/javascript">
			jQuery(function($) {
				var oTable1 = 
				$('#table')
			
				.dataTable( {
					bAutoWidth: false,
					"aoColumns": [
					  { "bSortable": false },
					  null,null,null,null,null,null,
					  { "bSortable": false }
					],
					"aaSorting": [],
					
					language: {
				        "sProcessing": "处理中...",
				        "sLengthMenu": "显示 _MENU_ 项结果",
				        "sZeroRecords": "没有匹配结果",
				        "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
				        "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
				        "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
				        "sInfoPostFix": "",
				        "sSearch": "搜索:",
				        "sUrl": "",
				        "sEmptyTable": "表中数据为空",
				        "sLoadingRecords": "载入中...",
				        "sInfoThousands": ",",
				        "oPaginate": {
				            "sFirst": "首页",
				            "sPrevious": "上页",
				            "sNext": "下页",
				            "sLast": "末页"
				        },
				        "oAria": {
				            "sSortAscending": ": 以升序排列此列",
				            "sSortDescending": ": 以降序排列此列"
				        }
				    }
			    } );
			
			
				$(document).on('click', 'th input:checkbox' , function(){
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox')
					.each(function(){
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});
				});
				
				$( ".delete-dialog" ).on('click', function(e) {
					e.preventDefault();
					var id = $(this).data("id");
					$( "#delete-confirm" ).removeClass('hide').dialog({
						resizable: false,
						modal: true,
						title: "删除",
						buttons: [
							{
								html: "<i class='ace-icon fa fa-trash-o bigger-110'></i>&nbsp; 删除",
								"class" : "btn btn-danger btn-xs",
								click: function() {
									$( this ).dialog( "close" );
									location.href="/dev_manage/delete/"+id;
								}
							}
							,
							{
								html: "<i class='ace-icon fa fa-times bigger-110'></i>&nbsp; 取消",
								"class" : "btn btn-xs",
								click: function() {
									$( this ).dialog( "close" );
								}
							}
						]
					});
				});
				
				$("#menu_dev").addClass("active open");
				$("#menu_wellGroup").addClass("active");
			});
			function batchDelete(e){
				e.preventDefault();
				$( "#delete-confirm" ).removeClass('hide').dialog({
					resizable: false,
					modal: true,
					title: "删除",
					buttons: [
						{
							html: "<i class='ace-icon fa fa-trash-o bigger-110'></i>&nbsp; 删除",
							"class" : "btn btn-danger btn-xs",
							click: function() {
								$( this ).dialog( "close" );
								$("form").attr("action","/dev_manage/batchDelete").submit();
							}
						}
						,
						{
							html: "<i class='ace-icon fa fa-times bigger-110'></i>&nbsp; 取消",
							"class" : "btn btn-xs",
							click: function() {
								$( this ).dialog( "close" );
							}
						}
					]
				});
			}
			
		</script>
	</body>
</html>
